package com.pubinfo.passbook.api.controller.system;

import com.mashape.unirest.http.exceptions.UnirestException;
import com.pubinfo.passbook.api.service.TPersonFeedbackService;
import com.pubinfo.passbook.common.entity.TPersonFeedback;
import com.pubinfo.passbook.common.model.dto.feedback.TPersonFeedbackParam;
import com.pubinfo.passbook.common.model.vo.FeedbackListVo;
import com.pubinfo.passbook.common.model.dto.feedback.FeedbackParam;
import com.pubinfo.passbook.common.model.vo.base.JsonResult;
import com.pubinfo.passbook.common.model.vo.base.MyPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "Feedback")
@Api(tags = "用户问题反馈接口")
@Slf4j

public class PersonFeedbackController
{
    @Autowired
    TPersonFeedbackService tPersonFeedbackService;

    @PostMapping("insertFeedback")
    @ApiOperation(value = "新增用户反馈")
    public JsonResult<String> insertFeedback(FeedbackParam feedbackParam) throws UnirestException {
        return tPersonFeedbackService.addTPersonFeedback(feedbackParam);
    }



    @PostMapping("selectFeedbackList")
    @ApiOperation(value = "用户反馈列表")
    public JsonResult<MyPage<TPersonFeedback>> selectFeedbackList(@RequestBody TPersonFeedbackParam tPersonFeedbackParam) throws UnirestException {
        return JsonResult.success(new MyPage(tPersonFeedbackService.selectFeedbackList(tPersonFeedbackParam)));
    }

    @PostMapping("selectFeedbackDetailed")
    @ApiOperation(value = "查询用户反馈详细")
    public JsonResult<FeedbackListVo> selectFeedbackDetailed(String id){
        return  JsonResult.success(tPersonFeedbackService.selectFeedbackDetailed(id));
    }

    @PostMapping("updateFeedback")
    @ApiOperation(value = "将反馈状态修改为已解决")
    public JsonResult<Integer> updateFeedback(String id){
        return  JsonResult.success(tPersonFeedbackService.updateFeedback(id));
    }

}
